﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

using NUnit.Framework;

using NUnitResultsExplorer;

namespace NUnitResultsExplorerTests.Unit
{
    public class AssertsToStringConverterTests
    {
        [Test, TestCaseSource("GetConvertTestCases")]
        public void TestConvert(Object value, Type targetType, Object parameter, String cultureString, Object expectedValue)
        {
            var culture = CultureInfo.GetCultureInfo(cultureString);
            var c = new AssertsToStringConverter();
            var actualValue = c.Convert(value, targetType, parameter, culture);
            Assert.AreEqual(expectedValue, actualValue);
        }

        [Test, ExpectedException(typeof(NotImplementedException))]
        public void TestConvertBack()
        {
            var culture = CultureInfo.GetCultureInfo("en-GB");
            var c = new AssertsToStringConverter();
            c.ConvertBack(null, typeof(String), null, culture);
        }

        public IEnumerable<TestCaseData> GetConvertTestCases()
        {
            yield return new TestCaseData(null, typeof(Nullable<Int32>), null, "en-GB", "[N/A]");
            yield return new TestCaseData(1, typeof(Nullable<Int32>), null, "en-GB", "1");
            yield return new TestCaseData(25, typeof(Nullable<Int32>), null, "en-GB", "25");
        }
    }
}
